package com.isesol.api.example.rest.test;

import java.util.Map;

import com.isesol.api.rest.annoations.RestParam;
import com.isesol.api.rest.annoations.RestServiceClass;
import com.isesol.api.rest.annoations.RestServiceMethod;
import com.isesol.api.rest.model.base.BusinessResources;
import com.isesol.api.system.service.SysApiResourcesService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Peter Zhang
 */
@Service
@RestServiceClass(url = "api")
public class ApiResources extends BusinessResources {

    @Autowired
    SysApiResourcesService resourcesService;

    @RestServiceMethod(url = "syn2cache")
    public Object syn2cache(@RestParam(name = "service", required = false) String service) {
        Map<String, Object> result = null;
        if (StringUtils.isNotBlank(service)) {
            result = resourcesService.sync2cacheByService(service);
        } else {
            result = resourcesService.sync2cache();
        }
        return result;
    }
}